package com.sf.shiva.oms.common.constant;

import java.util.ArrayList;
import java.util.List;

/**
 * 
 * 描述：日志解析配置枚举类
 * 
 * <pre>
 * HISTORY
 * ****************************************************************************
 *  ID   DATE            PERSON            REASON
 *  1    2018年4月16日         LA.01367604           Create
 * ****************************************************************************
 * </pre>
 * 
 * @author LA.01367604
 * @version 1.0
 */
public enum LogParseConfigEnum {

    /** 微服务框架的日志文件 */
    SGS_MICRO_SERVICE("sgsMicro", "log4j", "TIMESTAMP LEVEL NDC THREAD LINE CLASS METHOD MESSAGE","yyyy-MM-dd HH:mm:ss","Lo4j-pattern: %d{UTF-8} %-5p [%t] %m%n [UTF-8]","UTF-8"),
    /** novatar服务的日志文件 */
    NOVATAR_SERIVCE("novatar","log4j","TIMESTAMP [THREAD] LEVEL CLASS(METHOD) - MESSAGE", "MM-dd HH:mm:ss.SSS","Lo4j-pattern: %d{UTF-8} %-5p [%t] %m%n [UTF-8]","UTF-8"),
    ;

    private String cfgName;// 配置名，id
    private String type;// 日志类型
    private String pattern;// 日志内容格式
    private String dateFormat;// 日期时间格式
    private String logName;// 日志文件名
    private String charset;// 日志编码格式

    private LogParseConfigEnum(String cfgName, String type, String pattern, String dateFormat, String logName, String charset) {
        this.cfgName = cfgName;
        this.type = type;
        this.pattern = pattern;
        this.dateFormat = dateFormat;
        this.logName = logName;
        this.charset = charset;
    }

    public String getCfgName() {
        return cfgName;
    }

    public void setCfgName(String cfgName) {
        this.cfgName = cfgName;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getPattern() {
        return pattern;
    }

    public void setPattern(String pattern) {
        this.pattern = pattern;
    }

    public String getDateFormat() {
        return dateFormat;
    }

    public void setDateFormat(String dateFormat) {
        this.dateFormat = dateFormat;
    }

    public String getLogName() {
        return logName;
    }

    public void setLogName(String logName) {
        this.logName = logName;
    }

    public String getCharset() {
        return charset;
    }

    public void setCharset(String charset) {
        this.charset = charset;
    }

    /**
     * 根据配置名获取配置项
     * 
     * @param cfg
     * @return
     * @author LA.01367604-2018年4月16日
     */
    public static LogParseConfigEnum getByCode(String cfg) {
        for (LogParseConfigEnum name : LogParseConfigEnum.values()) {
            if (cfg.equals(name.getCfgName())) {
                return name;
            }
        }
        return null;
    }

    public static List<String> getAllCfgName() {
        List<String> names = new ArrayList<>();
        for (LogParseConfigEnum elem : LogParseConfigEnum.values()) {
            names.add(elem.getCfgName());
        }
        return names;
    }


}
